<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib uri="http://sargue.net/jsptags/time" prefix="javatime" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <jsp:include page="../common/header.jsp"/>
    <jsp:include page="../../common/mydate.jsp"></jsp:include>
    <jsp:include page="../../common/validform.jsp"></jsp:include>
    <jsp:include page="../../common/layer.jsp"></jsp:include>
    <jsp:include page="../../common/webupload.jsp"></jsp:include>
    <jsp:include page="../../common/ueditor.jsp"></jsp:include>

    <style>
        <%--可公共--%>
        #uploadImg{
            text-align: center;
            line-height: 37px;
            top: 0px; left: 0px;
            width: 78px;
            height: 37px;
            overflow: hidden;
            bottom: auto;
            right: auto;
        }
    </style>
    <script>

        $(function () {
            /*上传图片预览*/
            $("#photo").change(function () {
                var url;
                var file = this.files[0];
                if (window.URL!=undefined) { // mozilla(firefox)
                    url = window.URL.createObjectURL(file) ;
                } else if (window.webkitURL!=undefined) { // webkit or chrome
                    url = window.webkitURL.createObjectURL(file) ;
                }
                if(url){
                    $("#img").attr("src", url).show();
                    $("#img").parent().attr("href", "javascript:void(0);");
                }

            });
        });
    </script>


</head>
<body>

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="${pathUrl}/admin/shopAd/index">广告管理</a></li>
        <li><a href="#">新增</a></li>
    </ul>
</div>
<form action="${pathUrl}/admin/shopAd/saveOrUpdate" class="vfrom" enctype="multipart/form-data" method="post"  >
<input type="hidden" name="id" value="${shopAd.id }">
<input type="hidden" name="is_add" value="${is_add }">
<div class="session-main">
    <div class="formbody">
        <ul class="forminfo">
            <li><label>名称<b>*</b></label><input value="${shopAd.name }" datatype="*" nullmsg="请输入广告名称！" name="name" id="name"  type="text" class="dfinput"><i class="Validform_checktip">请输入名称</i></li>
            <li><label>跳转链接<b>*</b></label><input name="targetUrl" id="targetUrl" datatype="*" nullmsg="请输入跳转链接！" value="${shopAd.targetUrl }" type="text" class="dfinput"><i class="Validform_checktip">请输入跳转链接</i></li>
            <li><label>头像<b>*</b></label><input name="adImg" id="adImg" type="hidden" value="${shopAd.adImg }"  datatype="*" nullmsg="请选择图像！">
                <span style="display: inline-block;" id="adImgDiv" >选择文件</span>
                <span style="display: inline-block;" id="tupian">
            	  <c:if test="${!empty shopAd.adImg }">
                      <a href="${pathUrl}/${shopAd.adImg}" target='_black'><img alt="" src="${pathUrl}/${shopAd.adImg}" style="width:30px;height:30px;"></a>
                  </c:if>
            	</span>
                <i id="imgTxt" class="Validform_checktip">请上传图片</i>
            </li>
            <li><label>有效时间<b>*</b></label>
                <input name="startTime" id="startTime" datatype="*" nullmsg="请选择开始时间！" value="<javatime:format value="${shopAd.startTime}" pattern="yyyy-MM-dd HH:mm:ss" />" placeholder="开始时间" <c:if test="${empty shopAd.id}">readonly="readonly" </c:if> onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="dfinput" style="width: 140px;">
                <input name="endTime" id="endTime"  datatype="*" nullmsg="请选择结束时间！" value="<javatime:format value="${shopAd.endTime}" pattern="yyyy-MM-dd HH:mm:ss" />"  placeholder="结束时间" <c:if test="${empty shopAd.id}">readonly="readonly" </c:if>  onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="dfinput" style="width: 140px;">
          	    <i class="Validform_checktip"></i>
            </li>
            <li><label>备注</label><textarea name="remark" cols="" rows="" class="textinput">${shopAd.remark }</textarea></li>
            <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存">
               <input type="button" class="btn" onclick="javascript:window.location.href='${pathUrl}/admin/shopAd/index'" value="返回" style=" background: #57e980;">
            </li>
        </ul>
    </div>
</div>
</form>
<script type="text/javascript">
    $(function(){

        //表单验证
        $(".vfrom").Validform();

        createWebUploader("#adImgDiv",function(result){
            ydlMsg("上传成功");
            $("#imgTxt").html("上传成功");
            $("#adImg").val(result.data.url);
            $("#tupian").empty();
            $("#tupian").html("<a href='${pathUrl}"+result.data.url+"' target='_black'><img src='${pathUrl}"+result.data.url+"' style='width: 40px;height:40px;'/></a>");
        });



    });
</script>
</body>
</html>